<template>
    <div class="modify-dialog">
      <slot>
        <el-button size="small" type="primary" @click="showDialog()">
          新增材料分类
        </el-button>
      </slot>
      <el-dialog v-bind="dialogOpts" :visible.sync="dialogVisible">
        <Form v-bind="formOpts" v-on="formEvent">
            <template #operator>
            </template>
          <template #formBtn>
            <div class="dialog-footer">
              <el-button @click="dialogVisible = false">取 消</el-button>
              <el-button type="primary" @click="onConfirm"> 确 定 </el-button>
            </div>
          </template>
        </Form>
      </el-dialog>
    </div>
  </template>
  
  <script>
  import { mapGetters } from "vuex";
  import ProductInput from "./ProductInput.vue";
  import modifyMixins from "@/mixins/modifyMixins.vue";
  export default {
    mixins: [modifyMixins],
    components: {
      ProductInput,
    },
    data() {
      return {
        dialogWidth: "600px",
        openStatus:false,
        form: {
          name: {
            tag: "el-input",
            label: "",
            value: "",
            props: {
              clearable: true,
              placeholder: "请输入材料分类名称",
            },
          }
        },
      };
    },
    computed: {},
    watch: {},
    mounted() {
    },
    methods: {
      showCreate(){
        
      },
      showDialog(modify = "add", row = {}) {
        // modify add为新增 edit为编辑
        this.dialogVisible = true;
        // this.row = row;
        // this.modify = modify || "add";
        // //获取分类和供应商下拉数据
        // this.form.supplierId.items = this.$store.getters.supplierListItems;
        // this.form.classificationId.items =this.$store.getters.categoryListItems;
        // const keys = ["status"];
        // //遍历 form参数
        // // console.log(this.form,'form')
        // for (const key in this.form) {
        //   let defValue = "";
        //   if (Array.isArray(this.form[key].value)) defValue = [];
        //   if (Object.hasOwnProperty.call(row, key))
        //     this.form[key].value = row[key];
        //   else this.form[key].value = defValue;
        //   this.form[key].hidden = false;
        //   if (modify == "add") this.form[key].hidden = keys.includes(key);
        // }
        // this.formKey = this.$quinn.guid();
       
      },
      onSubmit(form) {
       this.$api.classificationClassificationAdd(form).then(res=>{
        if(res.status == 1) {
            this.dialogVisible = false;
            this.$message({
          message: '操作成功',
          type: 'success'
        });
        this.$emit('send1',)
        }else{
            this.$message.error('错了哦，这是一条错误消息');
        }
       
       })
      },
    },
  };
  </script>
  
  <style lang="less" scoped></style>
  